package com.hd.trans.network.bean.aiChat

import com.hd.trans.R
import com.hd.trans.db.bean.AIChatType
import com.hd.trans.network.PreferenceMgr
import com.hd.trans.network.bean.DataResponse
import java.io.Serializable

/**
 * AI翻译：创建任务接口返回数据
 */
data class AiCreateTaskResponse constructor(
    val tasktoken: String,
    val timestamp: String,
    var task_id: String? = "",
) : DataResponse()


/**
 * AI翻译：对话接口、查询任务接口返回数据
 */
data class AiChatResponse(
    val code: Int,
    var output: String,
    var message: String,
    var status: String
    ) : Serializable {
        //2105代表需要轮询
        fun isSuccess(): Boolean {
            return code == 10000 || code == 2105
        }
    }

/**
 * Sse 接口返回数据解析
 * @property output String
 * @property index Int
 * @property stop Int（1：结束）
 * @constructor
 */
data class AiChatSseFrg(
    var output: String = "",
    var reasoning: String = "",
    var index: Int = 0,
    var stop: Int = 0,
    val finish: Int = 0
)
//{"code":100422,"message":"The given data was invalid.","errors":{"account":["The account field is required."],"usertoken":["The usertoken field is required."]}}
data class AiChatError(
    val code: Int,
    val message: String
) : Serializable

/**
 * 回答内容
 * @property output 答案
 * @property dataType AIDataType
 * @constructor
 */
data class AIAnswer(
    var output: String,
    var dataType: AIDataType = AIDataType.QUESTION,
    var questionList: MutableList<String> = mutableListOf(),
    var placeholder: Int = R.mipmap.icon_chat_head_default,
    var explore: AIExplore = AIExplore.WORK,
    var status: TaskStatus = TaskStatus.WAIT,
    var scene: AIChatType = AIChatType.TRANSLATOR,
    var headUrl: String? = "",
    var createTime: Long = PreferenceMgr.getInstance().serverTimeStamp
)

/**
 * 列表item 数据类型
 * @property dataType 数据类型（0：提问，1：回答,2：title,3:固定提示语,4:探索）
 * @constructor
 */
enum class AIDataType(var dataType: Int) {
    /**
     * 问题
     */
    QUESTION(0),

    /**
     * 回答
     */
    ANSWER(1),

    /**
     * 时间title
     */
    TITLE(2),

    /**
     * 固定提示语
     */
    COMM_TIPS(3),

    /**
     * 探索选项
     */
    EXPLORE_TOP(4),
}

/**
 * 探索
 * @property title 标题
 * @property question 问题
 * @constructor
 */
enum class AIExplore(var title: String, var question: String) {
    WORK("工作学习", "长方形的长是12米，宽是2米，长方形的周长是多少？"),
    SPACE_EXPLORE("宇宙探索", "宇宙真的存在外星人吗？"),
    COOK("美食烹饪", "如何做番茄炒鸡蛋？"),
    TRANSLATION("语言翻译", "周末一起聚餐吧，用英文怎么说？"),
    KEEP_HEALTHY("健康养生", "喝枸杞对身体好吗？"),
    FORTUNE("星座运势", "天秤座的星座运势？"),
}

/**
 * 任务状态
 * @property value String
 * @constructor
 */
enum class TaskStatus(var value: String) {
    WAIT("wait"),
    DONE("done"),
    ERROR("done"),
}

enum class AIEventSSE(var value: String) {
    MESSAGE("message"),
    ERROR("error")
}